package com.learn.http.doc;

import com.learn.http.JsonUtil;
import com.learn.http.OkHttpUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;

/**
 * @author : Yu.Tan
 * @date : 2023/5/12 15:48
 * @desc : **
 */
@Slf4j
public class TestHttp {
    public static void main(String[] args) {

        testB();
    }

    public static void testA() {
        Map<String, String> headers = SignDocUtil.makeDocSignHeader("b5e7c6146ffe63bb", "6a884a7d027ece3b404228598638b5d9");
        String url = "https://marketing.gwm.cn/dealer-platform-test/api/smart/phone/generate/audio/url?callId=7223968972754915380";
        OkHttpUtil.get(url, headers, ((response, content) -> {
            log.info("查询: {}|{}|{}", url, null, content);
            return null;
        }));
    }

    public static void testB() {
        Map<String, String> headers = SignDocUtil.makeDocSignHeader("b5e7c6146ffe63bb", "6a884a7d027ece3b404228598638b5d9");
        String url = "https://marketing.gwm.cn/dealer-platform-test/api/smart/phone/sales/querySalesInfo";
        QuerySalesInfoRequest request = new QuerySalesInfoRequest();
        request.setFactSalesId("1396767701490180098");
        request.setOemDealerId("130628");
        OkHttpUtil.post(url, JsonUtil.writeValueAsString(request), OkHttpUtil.MediaType.JSON, headers, ((response, content) -> {
            log.info("查询: {}|{}|{}|", url, JsonUtil.writeValueAsString(request), content);
            return null;
        }));
    }

    @Data
    static class QuerySalesInfoRequest {
        private String oemDealerId;
        private String factSalesId;
        private List<String> salesPhones;
        private List<String> telePhones;
    }

    @Data
    static class QuerySalesInfoResponse {
        private List<SalesInfoResponse> salesInfos;

        @Data
        static class SalesInfoResponse {
            private String createTime;
            private String factSalesId;
            private String oemDealerId;
            private String salesName;
            private List<String> salesPhones;
            private List<String> telePhones;
        }
    }
}
